#pragma once

#include <queue> 
#include <vector>
#include "Message.h"
using namespace std;

typedef priority_queue<Message, vector<Message>, MsgCmp> MsgQueue;

class MessageDispatcher
{
private:
	MessageDispatcher() {}
	MessageDispatcher(const MessageDispatcher&) {}

public:
	static MessageDispatcher& GetInstance()
	{
		static MessageDispatcher s_inst;
		return s_inst;
	}

	int SendMessage(int iSender, int iReceiver, MST eType, void* pMsgData = NULL, int iDelay = 0);
	
	int Tick();

private:
	int _ProcMsg(int iSender, int iReceiver, MST eType, void* pMsgData);

private:
	MsgQueue m_stQueue;
};

#define MD MessageDispatcher::GetInstance()